<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        section{
            border-radius: 10px;
            background-color: #f4f4f4;
            height: 200px;
            width: 400px;
            margin: 0 auto;
            padding: 10px;
        }
        iframe{
            margin-top: 5px;
            width: 395px;
            height: 160px;
        }
    </style>
</head>
<body>
<section>
    <div>发送信息<input></input><button>发送</button></div>
    <div>目标接收窗口</div>
    <iframe src="http://localhost:63342/html5/ch02/host.html"></iframe>
</section>
<script type="text/javascript">
    var iframe_win = document.querySelector("iframe").contentWindow;
    document.querySelector('button').addEventListener('click',function(e) {
        e.preventDefault();
        iframe_win.postMessage(
                document.querySelector("input").value,
                "http://localhost:63342/html5/ch02"
        );
    })
</script>
</body>
</html>